
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 01/13/2013 17:50:55
-- Generated from EDMX file: C:\Users\Chovi\Desktop\epitech-rss-reader\RssMVC4\ServiceRss\Models\Model.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [RSS];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_FeedManagerFeed]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Feeds] DROP CONSTRAINT [FK_FeedManagerFeed];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FeedManagers]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FeedManagers];
GO
IF OBJECT_ID(N'[dbo].[Feeds]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Feeds];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'FeedManagers'
CREATE TABLE [dbo].[FeedManagers] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserName] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Feeds'
CREATE TABLE [dbo].[Feeds] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Url] nvarchar(max)  NOT NULL,
    [Title] nvarchar(max)  NOT NULL,
    [FeedManagerId] int  NOT NULL,
    [isRead] bit  NOT NULL,
    [DateRead] datetimeoffset  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'FeedManagers'
ALTER TABLE [dbo].[FeedManagers]
ADD CONSTRAINT [PK_FeedManagers]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Feeds'
ALTER TABLE [dbo].[Feeds]
ADD CONSTRAINT [PK_Feeds]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [FeedManagerId] in table 'Feeds'
ALTER TABLE [dbo].[Feeds]
ADD CONSTRAINT [FK_FeedManagerFeed]
    FOREIGN KEY ([FeedManagerId])
    REFERENCES [dbo].[FeedManagers]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FeedManagerFeed'
CREATE INDEX [IX_FK_FeedManagerFeed]
ON [dbo].[Feeds]
    ([FeedManagerId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------